package com.example.common.core.utils;

public class UserUtils {

    private static ThreadLocal<Integer> threadLocal = new ThreadLocal<>();

    public static void setUid(Integer uid){
        // Thread thread = Thread.currentThread();
        // String name = thread.getName();
        // long id = thread.getId();
        // int hashcode = threadLocal.hashCode();
        // String s = String.format("当前线程名: %s , 线程id: %s , 使用的threadLocal的对象地址: %s", name, id,hashcode);
        // System.out.println(s);
        threadLocal.set(uid);
    }

    public static Integer getUid(){
        return threadLocal.get();
    }

    public void remove(){
        threadLocal.remove();
    }
}